angular.module('mamApp').factory('MessageManager', ['$http', 'api', 'paramsManager', function ($http, api, paramsManager) {
    var MessageManager = {

        /**
         * 消息添加
         * @param params
         * @returns
         */

        messageAdd: function (params) {
            return $http.post(api + '/admin/messages/message', params).then(function (result) {
                return result;
            });
        },
        /**
         * 消息修改
         * @param params
         * @returns
         */

        messageEdit: function (messageId, params) {
            return $http.put(api + '/admin/messages/' + messageId, params).then(function (result) {
                return result;
            });
        },
        /**
         * 消息删除
         * @param params
         * @returns
         */

        messageDelete: function (messageIds) {
            console.log({idSet: messageIds.join(",")})
            return $http.delete(api + '/admin/messages/'+messageIds.join(",")).then(function (result) {
                return result;
            });
        },
        /**
         * 消息列表
         * @param params[pageNo,pageSize]
         * @returns result
         */
        messageList: function (params, query) {
            return $http.get(api + '/admin/messages/' + paramsManager.params(params) + paramsManager.query(query)).then(function (result) {
                return result;
            });
        },
        /**
         * 消息详情
         * @returns result
         */
        messageDetail: function (messageId) {
            return $http.get(api + '/admin/messages/' + messageId).then(function (result) {
                return result;
            });
        }


    };

    return MessageManager;
}]);
